home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume10 / cbw / part05 < prev    next >
Encoding:
Internet Message Format  |  1987-06-17  |  54.7 KB

  1. Path: seismo!uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i005:  Crypt Breaker's Workbench, Part05/11
  5. Message-ID: <387@uunet.UU.NET>
  6. Date: 19 Jun 87 03:06:10 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 1998
  9. Approved: rs@uunet.uu.net
  10.  
  11. Submitted by: Robert W. Baldwin <BALDWIN@XX.LCS.MIT.EDU>
  12. Mod.sources: Volume 10, Issue 5
  13. Archive-name: cbw/Part05
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 5 (of 11)."
  22. # Contents:  Read.me cipher.c eclass.c knit.c zeecode.perm
  23. # Wrapped by rs@uunet on Wed Jun 17 18:17:17 1987
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f Read.me -a "${1}" != "-c" ; then 
  26.   echo shar: Will not over-write existing file \"Read.me\"
  27. else
  28. echo shar: Extracting \"Read.me\" \(9793 characters\)
  29. sed "s/^X//" >Read.me <<'END_OF_Read.me'
  30. X
  31. XUNPACKING NOTES [by Rich $alz]
  32. X    There Usenet distribution of CBW includes six files that have
  33. Xbeen UUENCODE'd because they contain non-printing characters:
  34. X        UU.foo UU.graphics UU.test UU.test1 UU.test2 UU.test3
  35. XYou must first decode these files before using them; one of
  36. Xthe command sets will do the trick:
  37. X    for I in UU.* ; do uudecode $I ; done    -- /bin/sh
  38. X    foreach I (UU.*)            -- C shell
  39. X        uudecode $I                --
  40. X    end                    --
  41. X
  42. X    This directory contains the source, documentation, and
  43. Xauxilary files for the Crypt Breakers Workbench (cbw).  CBW is
  44. Xa multi-window integrated workbench of tools that help a cryptanalist
  45. Xread files encrypted with the BSD4.2 crypt command.  Anyone
  46. Xmay copy, modify, use, or redistribute this system.  It was
  47. Xoriginally written by Robert W. Baldwin at MIT.
  48. X
  49. X
  50. XGETTING STARTED
  51. X
  52. X    A user's manual is provided in cbw.doc.  The scribe source
  53. Xfor the user's manual is in cbw.mss.  The file Index briefly describes
  54. Xthe various programs in this directory.
  55. X
  56. X    CBW is written in C and distributed with the source code to
  57. Xencourage people to play with it.  It should run on any display
  58. Xterminal.  Read the users manual for information on terminal
  59. Xcompatibility.
  60. X
  61. X
  62. X    
  63. XTO COMPILE CBW
  64. X
  65. X    Execute "make" with no arguments.  CBW uses routines from the termcap
  66. Xand curses libraries, but it does not use the full curses package.
  67. X
  68. X
  69. XA FEW OTHER NOTES
  70. X
  71. X    Page 2 of the users manual mentions that CBW cannot work
  72. X    against files that have been run through compress (1) before
  73. Xencryption.  Personally, I would prefer to have a DES-based
  74. Xself-inverse cipher.  Most DES programs need to be told whether they
  75. Xare in encrypt or decrypt mode.  However, IBM only grants free use of
  76. XDES if it is used according to NBS guidelines, and self-inverse is not
  77. Xone of the accepted operating modes.
  78. X
  79. X
  80. XTESTING
  81. X
  82. X     The following is a step by step sequence of commands to exercise
  83. Xthe Crypt Breakers Workbench.  It demonstrates how easily crypt files
  84. Xcan be broken.
  85. X
  86. X   1. Edit  stats.slice to set the name of the directory that contains the
  87. X      statistics files.  Statistics for scribe documents are included with
  88. X      the source files.
  89. X
  90. X      The  stats.slice  file  also  defines the location of the dictionary
  91. X      used by the lookup-pattern  command.    The  default  dictionary  is
  92. X      /usr/dict/words.    The  dictionary is just a list of words, one per
  93. X      line.  Case does not matter.
  94. X
  95. X   2. Execute 'source  stats.slice'  to  initialize  the  necessary  shell
  96. X      variables.
  97. X
  98. X   3. If there is a .slice file for your terminal type (e.g., vt100.slice,
  99. X      or h19.slice), execute source on that file.   This  initializes  the
  100. X      graphics map and key map.
  101. X
  102. X   4. Print  out  cbw.doc,  so you can read it after you have decided that
  103. X      you can't figure out how the program works.
  104. X
  105. X   5. Copy test3.perm and .cipher to foo.perm and foo.cipher.    The  .txt
  106. X      files contain the original plaintext.
  107. X
  108. X   6. Execute 'cbw foo'.
  109. X
  110. X   7. The  cursor  will  on the command line.  Use the arrow keys (or C-P,
  111. X      C-N, C-F, C-B) to move the cursor to the upper lefthand position  of
  112. X      the  decryption  window.   Try typing '@Device[Dover]'.  Notice that
  113. X      most of the characters you type  deduced  other  characters  in  the
  114. X      block.
  115. X
  116. X   8. The  'D'  in  'Dover'  is wrong.  Using the arrow keys, position the
  117. X      cursor over the 'D' and type 'd'.
  118. X
  119. X   9. Advance to the position after the ']' and  type  C-T.    A  list  of
  120. X      possible  characters  for this position will be displayed.  The list
  121. X      is sorted with the most likely character on the left.   Notice  that
  122. X      many characters are not possible because they would deduce non-ascii
  123. X      characters elsewhere in the  block,  or  they  would  conflict  with
  124. X      previously accepted guesses.
  125. X
  126. X      Try  guessing  tab,  comma  and linefeed for the character after the
  127. X      ']'.  Use C-G to undo each guess.  Delete and C-D do not restore the
  128. X      old  state,  they  just  erase  the  wiring  that  was  deduced by a
  129. X      particular character.
  130. X
  131. X  10. Move the cursor down to the command line.  You can use emacs  cursor
  132. X      characters  (C-N,  C-P, C-F, C-B) or the arrow keys.  Unfortunately,
  133. X      C-U does not work as in emacs.  The C-X key or F4 will jump directly
  134. X      to the command line.
  135. X
  136. X  11. Type  'pw  '.    The  space  will  cause  command completion for the
  137. X      probable-word guessing command.  Type F2 (or C-S) to advance to  the
  138. X      first  argument,  and  enter  the  file name 'mss.words'.  That file
  139. X      contains a list of keywords used  by  the  Scribe  (Finalword)  text
  140. X      formatter.    Press  F2  to  advance  to  the second argument, which
  141. X      specifies a cut-off level for automatically accepting guesses.   The
  142. X      level  is the maximum number of standard deviations that the scoring
  143. X      function can be away from its expected value.  Enter 1.2, and  press
  144. X      return to invoke the command.
  145. X
  146. X  12. A  partially filled in block will appear in the guessing window.  To
  147. X      accept the result of this command, press F3 (or C-A).
  148. X
  149. X  13. Try the pword guess command again with a level of 3.   To  do  this,
  150. X      just  move  to  the  command  line, change the 1.2 to a 3, and press
  151. X      return.  Again F3 accepts the guess.  If  some  guesses  look  wrong
  152. X      (such  as the 'F' on the second line under the '[Article]'), you can
  153. X      correct them using the editor in the decryption block window.
  154. X
  155. X  14. Advance to block  1  of  the  file  by  moving  the  cursor  to  the
  156. X      decryption  window and pressing F2 (or C-S).  F1 (or C-R) moves back
  157. X      one block, F2 moves ahead one block.
  158. X
  159. X  15. The second block is likely to  be  plain  english  with  few  scribe
  160. X      commands.    Move  to the command window, type C-U to erase the line
  161. X      and type 'bi ' to  setup  the  bigram  guessing  command.    Try  an
  162. X      acceptance  level  of  1.0  and  a minimum probability of 0.6.  Type
  163. X      return to invoke the command.
  164. X
  165. X  16. After a short wait (~15  seconds),  a  partial  block  will  appear.
  166. X      Accept the guess with the F3 key in the guessing window.
  167. X
  168. X  17. Try  looking  up a pattern in the dictionary.  In the command window
  169. X      type 'look ', use F2 to advance to the  pattern,  and  type  in  the
  170. X      pattern  '....llit.', and press return.  This will match against the
  171. X      word 'satellite' if it is in you site's dictionary.
  172. X
  173. X  18. One could go on like this, but let's skip  ahead  by  loading  in  a
  174. X      previously  saved state.  Invoke the load command (it loads the file
  175. X      foo.perm, just as save dumps to foo.perm (making this command take a
  176. X      filename  is  a  good implementation exercise)).  Type C-U, 'load ',
  177. X      and return.  Notice that all the work so  far  is  replaced  by  the
  178. X      information in the .perm file.  This can be considered a feature.
  179. X
  180. X  19. Use  the  F1 and F2 keys in the decryption window to view the blocks
  181. X      that have been solved.  Notice that a fully solved  block  does  not
  182. X      specify  all  the wirings of the block key (permutation).  Typically
  183. X      only 105 of the 128 wires are used.
  184. X
  185. X  20. Lets try deducing the inter-block relationship (zee).   Execute  the
  186. X      clear-zee command.
  187. X
  188. X  21. Execute  knit  blocks 0 through 3 with a min show count of 20.  This
  189. X      means that the program should only show you guesses that  deduce  20
  190. X      or more wirings of the zee permutation.  Press return to invoke this
  191. X      guessing strategy.  The cursor will move  to  the  guessing  window.
  192. X      Press F2 to start the first round of guessing.
  193. X
  194. X      The running time of the knit command is exponential in the number of
  195. X      blocks knitted, and it will run for a very long time if any  of  the
  196. X      blocks  are  decrypted incorrectly.  This means that it is better to
  197. X      leave a position blank than to guess at it.
  198. X
  199. X  22. The program moves to block 4 and shows you the characters in block 4
  200. X      that would be deduced from block 3 given the deduced wirings of zee.
  201. X      If these look reasonable, press F3 to accept the guess, and press F2
  202. X      to try the next guess.  To reject a guess, press F2 without pressing
  203. X      F3.
  204. X
  205. X  23. Now that part of zee is known, try propagating the settings of block
  206. X      1 into block 0 using zee.  The propagate command will do this.  Also
  207. X      try propagating blocks 2, 3, and 4 to zero.
  208. X
  209. X      Notice that the number of known wires can increase without  deducing
  210. X      additional characters in the block.
  211. X
  212. X  24. There should be a command that propagates information between groups
  213. X      of blocks, but for now you must do this one block at a time.   After
  214. X      propagating  block 1 - 4 to block zero, and block zero to blocks 1 -
  215. X      4, et cetera, try the knit command again.
  216. X
  217. X  25. Propagate block 4 to 5  to  provide  a  framework  to  evaluate  new
  218. X      guesses.
  219. X
  220. X  26. Knit block 0 through 4 with a minimum show level of 2.  You may want
  221. X      to skip accepting guesses that do not deduce any characters.  Repeat
  222. X      this process with a show level of 1.
  223. X
  224. X  27. The  program  should  now  know  all 256 wirings of zee.  Repeat the
  225. X      process of propagating information  between  blocks  until  all  128
  226. X      wires of the block zero are known.
  227. X
  228. X  28. Save  your  work  with the save-permutations command (on the command
  229. X      line type 'sa ' and press return).  This writes the file foo.perm.
  230. X
  231. X  29. Exit the program with the quit command.
  232. X
  233. X  30. Copy foo.perm to zeecode.perm.
  234. X
  235. X  31. Execute 'zeecode < foo.cipher | more '.  This  program  reads  CBW's
  236. X      save  file  to  find  the  permutation  for  block  zero and the Zee
  237. X      permutation  that  describes  how  the  remaining  block  keys   are
  238. X      generated.    Using  this  information it decodes standard input and
  239. X      writes on standard output.
  240. X
  241. X  32. That's all.
  242. END_OF_Read.me
  243. if test 9793 -ne `wc -c <Read.me`; then
  244.     echo shar: \"Read.me\" unpacked with wrong size!
  245. fi
  246. # end of overwriting check
  247. fi
  248. if test -f cipher.c -a "${1}" != "-c" ; then 
  249.   echo shar: Will not over-write existing file \"cipher.c\"
  250. else
  251. echo shar: Extracting \"cipher.c\" \(9641 characters\)
  252. sed "s/^X//" >cipher.c <<'END_OF_cipher.c'
  253. X/* 
  254. X * Routines for operating on cipher blocks.
  255. X *
  256. X * Robert W. Baldwin, January 1985.
  257. X */
  258. X
  259. X
  260. X#include    <stdio.h>
  261. X#include    <math.h>
  262. X#include    "window.h"
  263. X#include    "specs.h"
  264. X#include    "cipher.h"
  265. X
  266. X
  267. X#define    DEBUG    FALSE
  268. X
  269. X
  270. X/* Decode the cblock into pblock using perm.
  271. X * Return FALSE if find a non-ascii character, else 1.
  272. X */
  273. Xdecode(cblock, pblock, perm)
  274. Xchar    cblock[];
  275. Xint        pblock[];
  276. Xint        perm[];
  277. X{
  278. Xint iplace;        /* Index into ciphertext block. */
  279. Xint spchar;        /* Plaintext char not unshifted. */
  280. Xint pchar;        /* Plaintext char. */
  281. Xint    good;        /* Plaintext doesn't have any unacceptable chars in it. */
  282. X
  283. Xgood = TRUE;
  284. Xfor (iplace = 0 ; iplace < BLOCKSIZE ; iplace++) {
  285. X    spchar = perm[(iplace+cblock[iplace])&MODMASK];
  286. X    if (spchar == -1) {
  287. X        pchar = -1;
  288. X        }
  289. X    else {
  290. X        pchar = (spchar-iplace) & MODMASK;
  291. X        if (notascii(pchar))  {
  292. X            good = FALSE;
  293. X            }
  294. X        }
  295. X    pblock[iplace] = pchar;
  296. X    }
  297. Xreturn(good);
  298. X}
  299. X
  300. X
  301. X/* Searches for string in block.
  302. X * Returns position it found that didn't have conflicts, or -1.
  303. X * If found, it will add to perm all the deduced wirings.
  304. X * If perm is not initially all -1, search will not accept any
  305. X * position that conflicts with the initial wirings, nor will
  306. X * it mutate any of those wirings.
  307. X */
  308. Xint    search(cipher, perm, initpos, thing)
  309. Xchar    *cipher;
  310. Xint        *perm;
  311. Xint        initpos;
  312. Xchar    *thing;        /* NULL terminated string. */
  313. X{
  314. X    int    iplace;        /* Current placement of trigram in plaintext block. */
  315. X    int i;            /* Index for initializing arrays. */
  316. X    int    pchar;        /* Plaintext character. */
  317. X    int    spchar;        /* Plaintext character cyclically shifted by its pos. */
  318. X    int    *spstkp;
  319. X    int    spstack[BLOCKSIZE];
  320. X    int    *scstkp;
  321. X    int    scstack[BLOCKSIZE];
  322. X    int    scchar;        /* Ciphertext character cyclically shifted by its pos. */
  323. X    int    offset;
  324. X    int    thinglen;
  325. X    char *p;
  326. X
  327. X    p = thing;
  328. X    for (thinglen = 0 ; *p++ != 0 ; thinglen++) ;
  329. X
  330. X  for (iplace = initpos ; iplace < BLOCKSIZE-thinglen ; iplace++) {
  331. X    spstkp = spstack;
  332. X    scstkp = scstack;
  333. X    for (offset = 0 ; offset < thinglen ; offset++) {
  334. X        pchar = ((int) thing[offset]);
  335. X        spchar = (pchar + iplace + offset) & MODMASK;
  336. X        scchar = (cipher[iplace + offset] + iplace + offset) & MODMASK;
  337. X        if ((perm[spchar] != -1  ||  perm[scchar] != -1)
  338. X         && (perm[spchar] != scchar))  {
  339. X                while (spstkp > &spstack[0]) perm[*(--spstkp)] = -1;
  340. X                while (scstkp > &scstack[0]) perm[*(--scstkp)] = -1;
  341. X                goto nextplace;
  342. X                }
  343. X        perm[spchar] = scchar;
  344. X        *spstkp++ = spchar;
  345. X        perm[scchar] = spchar;
  346. X        *scstkp++ = scchar;
  347. X        }
  348. X    return(iplace);
  349. X    nextplace: ;
  350. X    }
  351. X  return(-1);
  352. X}
  353. X
  354. X
  355. X/* Fill in the pvec with the characters decoded from assuming
  356. X * that the ciphertext character at position firstpos maps to
  357. X * the plaintext character firstplain.
  358. X * Return the number of characters added to pvec not counting
  359. X * the termination character (NONE) that we always add.
  360. X * If any of the characers decoded to non-ascii values, then
  361. X * return ERROR (a negative number).
  362. X * Also return ERROR if the guess would conflict with the ones already
  363. X * in eci->perm.
  364. X */
  365. Xint    decode_class(eci, firstpos, firstplain, pvec)
  366. Xecinfo    *eci;
  367. Xint        firstpos;
  368. Xint        firstplain;
  369. Xint        *pvec;
  370. X{
  371. X    int        x,y;
  372. X
  373. X    firstpos = MODMASK & firstpos;
  374. X    firstplain = CHARMASK & firstplain;
  375. X
  376. X    x = eci->scipher[firstpos];
  377. X    y = MODMASK & (firstplain + firstpos);
  378. X
  379. X    return(decode_wire(eci, x, y, pvec));
  380. X}
  381. X
  382. X
  383. X/* Fill in the pvec with the characters decoded from assuming
  384. X * that the permutation for this block maps x to y and vice-versa.
  385. X * Return the number of characters added to pvec not counting
  386. X * the termination character (NONE) that we always add (but not if
  387. X * we return ERROR).
  388. X * If any of the characers decoded to non-ascii values, then
  389. X * return ERROR (a negative number).
  390. X * Also return ERROR if the guess would conflict with the ones already
  391. X * in eci->perm.
  392. X * Also return ERROR if x == y.
  393. X */
  394. Xint    decode_wire(eci, x, y, pvec)
  395. Xecinfo    *eci;
  396. Xint        x;
  397. Xint        y;
  398. Xint        *pvec;
  399. X{
  400. X    decode_wire_but(eci, x, y, pvec, NONE, NONE);
  401. X}
  402. X
  403. X
  404. X/* Fill in the pvec with the characters decoded from assuming
  405. X * that the permutation for this block maps x to y and vice-versa.
  406. X * Return the number of characters added to pvec not counting
  407. X * the termination character (NONE) that we always add (but not if
  408. X * we return ERROR).
  409. X * If any of the characers decoded to non-ascii values, then
  410. X * return ERROR (a negative number).
  411. X * Also return ERROR if the guess would conflict with the ones already
  412. X * in eci->perm.
  413. X * Also return ERROR if x == y.
  414. X * DO NOT include any characters in the postions ranging from
  415. X * first to last inclusive.
  416. X */
  417. Xint    decode_wire_but(eci, x, y, pvec, first, last)
  418. Xecinfo    *eci;
  419. Xint        x;
  420. Xint        y;
  421. Xint        *pvec;
  422. Xint        first, last;
  423. X{
  424. X    int        delta;
  425. X    int        pos, firstflag;
  426. X    int        c,i;
  427. X    int        firstpos;
  428. X    int        otherpos;
  429. X    int        pvecindex;
  430. X
  431. X
  432. X    pvecindex = 0;
  433. X    pvec[pvecindex] = NONE;
  434. X    x = x & MODMASK;
  435. X    y = y & MODMASK;
  436. X    if (first > last)  {
  437. X        printf("\ndecode_wire_but called with first > last.\n");
  438. X        exit(0);
  439. X        }
  440. X
  441. X    if (perm_conflict(eci->perm,x,y)  ||  x == y) {
  442. X#if DEBUG
  443. X        printf("CANNOT accept the guess of %d wired to %d.\n",
  444. X                x, y);
  445. X#endif
  446. X        return(ERROR);
  447. X        }
  448. X
  449. X    firstpos = eci->permmap[x];
  450. X    if (firstpos != NONE) {
  451. X        delta = y - x;
  452. X        for_pos_in_class(pos, firstpos) {
  453. X            if (first <= pos && pos <= last)  continue;
  454. X            c = MODMASK & (eci->scipher[pos] + delta - pos);
  455. X            if (c != (c & CHARMASK))  return(ERROR);
  456. X            pvec[pvecindex++] = c;
  457. X            }
  458. X        }
  459. X
  460. X    otherpos = eci->permmap[y];
  461. X    if (otherpos != NONE) {
  462. X        delta = x - y;
  463. X        for_pos_in_class(pos, otherpos) {
  464. X            if (first <= pos && pos <= last)  continue;
  465. X            c = MODMASK & (eci->scipher[pos] + delta - pos);
  466. X            if (c != (c & CHARMASK))  return(ERROR);
  467. X            pvec[pvecindex++] = c;
  468. X            }
  469. X        }
  470. X
  471. X    pvec[pvecindex] = NONE;
  472. X    return(pvecindex);
  473. X}
  474. X
  475. X
  476. X
  477. X/* Fill in an interger buffer from the characters of a byte buffer.
  478. X * The buffers must have equal lengths.
  479. X */
  480. Xchar2buf(cptr, iptr, length)
  481. Xchar    *cptr;
  482. Xint        *iptr;
  483. Xint        length;
  484. X{
  485. X    int        i;
  486. X
  487. X    for (i = 0 ; i < length ; i++)  {
  488. X        *iptr++ = MODMASK & (*cptr++);
  489. X        }
  490. X}
  491. X
  492. X
  493. X/* Fill in a character buffer from the integers of a byte buffer.
  494. X * If the integer value is NONE, use nonechar instead.
  495. X * The buffers must have equal lengths.
  496. X */
  497. Xbuf2char(cptr, iptr, length, nonechar)
  498. Xchar    *cptr;
  499. Xint        *iptr;
  500. Xint        length;
  501. Xint        nonechar;
  502. X{
  503. X    int        i;
  504. X
  505. X    for (i = 0 ; i < length ; i++)  {
  506. X        if (*iptr != NONE)  {
  507. X            *cptr++ = MODMASK & (*iptr++);
  508. X            }
  509. X        else {
  510. X            *cptr++ = nonechar;
  511. X            }
  512. X        }
  513. X}
  514. X
  515. X
  516. X
  517. X/* Fill in an interger vector with the characters from a null
  518. X * terminated string.  The interger vector is terminated by the
  519. X * value NONE.
  520. X */
  521. Xstr2pvec(cptr, iptr)
  522. Xchar    *cptr;
  523. Xint    *iptr;
  524. X{
  525. X    while (*iptr++ = (MODMASK & *cptr++));
  526. X    *(--iptr) = NONE;
  527. X}
  528. X
  529. X
  530. X/* Fill in a null terminated string with the integers from a NONE
  531. X * terminated vector.
  532. X */
  533. Xpvec2str(cptr, iptr)
  534. Xchar    *cptr;
  535. Xint        *iptr;
  536. X{
  537. X    while (*iptr != NONE)  {
  538. X        *cptr++ = (MODMASK & *iptr++);
  539. X        }
  540. X    *cptr = 0;
  541. X}
  542. X
  543. X
  544. X/* Print a pvec on a stream.
  545. X */
  546. Xprint_pvec(out, pvec)
  547. XFILE    *out;
  548. Xint        *pvec;
  549. X{
  550. X    int        i,c;
  551. X
  552. X    i = 0;
  553. X    while (*pvec != NONE)  {
  554. X        c = *pvec++;
  555. X        if (i++ % 20 == 0) fprintf(out,"\n");
  556. X        write_char(out, c);
  557. X        }
  558. X    fprintf(out,"\n");
  559. X}
  560. X
  561. X
  562. X/* Returns number of wires added to permvec assuming
  563. X * that plaintext str occurs at pos.
  564. X * Fills in permvec.  Returns -1 if conflict.
  565. X * Note that the last entry in permvec is marked by x == -1.
  566. X * The permvec will not have duplicates and will not conflict
  567. X * with the perm specified by eci->perm.
  568. X */
  569. Xint        permvec_from_string(eci, str, pos, permvec)
  570. Xecinfo    *eci;
  571. Xchar    *str;
  572. Xint        pos;
  573. Xperment    permvec[];
  574. X{
  575. X    int        wcount;
  576. X    int        i, c, tmp;
  577. X    int        x,y;
  578. X    char    *cp;
  579. X    int        curpos;
  580. X
  581. X    if (pos < 0 || pos >= BLOCKSIZE)  {return(ERROR);}
  582. X
  583. X    wcount = 0;
  584. X    curpos = pos;
  585. X    cp = str;
  586. X    while ((c = (*cp & MODMASK)) != 0  &&  (curpos < BLOCKSIZE))  {
  587. X        x = eci->scipher[curpos];
  588. X        y = MODMASK & (c + curpos);
  589. X        if (perm_conflict(eci->perm, x, y))  {
  590. X            permvec[0].x = NONE;
  591. X            return(ERROR);
  592. X            }
  593. X        for (i = 0 ; i < wcount ; i++) {
  594. X            if ( (permvec[i].x == x  &&  permvec[i].y != y)
  595. X              || (permvec[i].x == y  &&  permvec[i].y != x)
  596. X              || (permvec[i].y == x  &&  permvec[i].x != y)
  597. X              || (permvec[i].y == y  &&  permvec[i].x != x) )  {
  598. X#if DEBUG
  599. X                printf("Conflict within permvec.\n");
  600. X#endif
  601. X                permvec[0].x = NONE;
  602. X                return(ERROR);
  603. X                }
  604. X            if ( (permvec[i].x == x  &&  permvec[i].y == y)
  605. X              || (permvec[i].x == y  &&  permvec[i].y == x) )
  606. X                break;
  607. X            }
  608. X        permvec[i].x = x;
  609. X        permvec[i].y = y;
  610. X        if (i >= wcount)  wcount++;
  611. X         curpos++;
  612. X        cp++;
  613. X        }
  614. X
  615. X    permvec[wcount].x = NONE;
  616. X    return(wcount);
  617. X}
  618. X
  619. X
  620. X
  621. X/* Copy routine for permvecs.
  622. X */
  623. Xpermvec_copy(from, to, maxnum)
  624. Xperment    from[];
  625. Xperment    to[];
  626. Xint        maxnum;
  627. X{
  628. X    int        i;
  629. X
  630. X    for (i = 0 ; i < maxnum ; i++)  {
  631. X        to[i] = from[i];
  632. X        if (from[i].x == NONE) break;
  633. X        }
  634. X}
  635. X
  636. X
  637. X/* Copy routine for pvecs.
  638. X */
  639. Xpvec_copy(from, to, maxnum)
  640. Xint        from[];
  641. Xint        to[];
  642. Xint        maxnum;
  643. X{
  644. X    int        i;
  645. X
  646. X    for (i = 0 ; i < maxnum ; i++)  {
  647. X        to[i] = from[i];
  648. X        if (from[i] == NONE) break;
  649. X        }
  650. X}
  651. X
  652. X
  653. X
  654. X/* Fills in pvec with the plaintext characters deduced
  655. X * from the wires in permvec that are not in the positions
  656. X * ranging from butfirst to butlast.  Returns -1 if any
  657. X * non-ascii chars are deduced, else count of chars.
  658. X */
  659. Xint        permvec2pvec(eci, permvec, pvec, butfirst, butlast)
  660. Xecinfo    *eci;
  661. Xperment    permvec[];
  662. Xint        pvec[];
  663. Xint        butfirst;
  664. Xint        butlast;
  665. X{    int        i, x, y;
  666. X    int        ccount;
  667. X    int        added;
  668. X
  669. X    ccount = 0;
  670. X
  671. X    for (i = 0 ; permvec[i].x != NONE ; i++)  {
  672. X        if (ccount >= BLOCKSIZE-1) break;
  673. X        x = permvec[i].x;
  674. X        y = permvec[i].y;
  675. X        added = decode_wire_but(eci, x, y, &(pvec[ccount]), butfirst, butlast);
  676. X        if (added < 0)  {
  677. X#if DEBUG
  678. X            printf("permvec wire decodes to non-ascii.\n");
  679. X#endif
  680. X            pvec[0] = -1;
  681. X            return(ERROR);
  682. X            }
  683. X        ccount += added;
  684. X        }
  685. X    pvec[ccount] = -1;
  686. X    return(ccount);
  687. X}
  688. END_OF_cipher.c
  689. if test 9641 -ne `wc -c <cipher.c`; then
  690.     echo shar: \"cipher.c\" unpacked with wrong size!
  691. fi
  692. # end of overwriting check
  693. fi
  694. if test -f eclass.c -a "${1}" != "-c" ; then 
  695.   echo shar: Will not over-write existing file \"eclass.c\"
  696. else
  697. echo shar: Extracting \"eclass.c\" \(9192 characters\)
  698. sed "s/^X//" >eclass.c <<'END_OF_eclass.c'
  699. X/*
  700. X * Equivalence class information about a cipher block.
  701. X *
  702. X * Bob Baldwin, January 1985.
  703. X */
  704. X
  705. X#include    <stdio.h>
  706. X#include    <math.h>
  707. X#include    "window.h"
  708. X#include    "terminal.h"
  709. X#include    "layout.h"
  710. X#include    "specs.h"
  711. X#include    "cipher.h"
  712. X
  713. X
  714. X#define    DEBUG    FALSE
  715. X
  716. X#define    MIN_SHOW_SCORE    (0.7)
  717. X#define    ECBLABEL1    "Equiv class guessing at level %6.3f  -- Please Wait"
  718. X#define    ECBLABEL2    "Equiv class guessing at level %6.3f  -- Done"
  719. X#define    ECBHELP "F3 enters guess, ^G undoes it."
  720. X
  721. X
  722. Xextern    char    mcbuf[];
  723. Xextern    ecinfo    gecinfo;
  724. Xextern    ecbdraw(), ecbfirst(), ecbenter(), ecbundo();
  725. X
  726. X/* Gloabal State. */
  727. Xfloat    ec_accept_level = 0.0;
  728. Xkeyer    ecbktab[] = {
  729. X        {CACCEPT, ecbenter},
  730. X        {CUNDO, ecbundo},
  731. X        {CGO_UP, jogup},
  732. X        {CGO_DOWN, jogdown},
  733. X        {CGO_LEFT, jogleft},
  734. X        {CGO_RIGHT, jogright},
  735. X        {0, NULL},
  736. X};
  737. X
  738. X
  739. X/* Routine invoked by user to put up the equivalence class
  740. X * guessing window.
  741. X * The window is drawn empty, and then filled in with the guess.
  742. X * Return NULL if command completes ok.
  743. X */
  744. Xchar    *ecbguess(str)
  745. Xchar    *str;            /* Command line */
  746. X{
  747. X    ecinfo    *ecbi;
  748. X    int        i;
  749. X    gwindow    *ecb;
  750. X
  751. X    ecb = &gbstore;
  752. X    ecbi = &gecinfo;
  753. X    ec_init(mcbuf, refperm(dbsgetblk(&dbstore)), ecbi);
  754. X
  755. X    if ((i = sscanf(str, "%*[^:]: %f", &ec_accept_level)) != 1)  {
  756. X        return("Could not parse acceptance level.");
  757. X        }
  758. X
  759. X    gbsswitch(ecb, ((char *) ecbi), ecbktab, ecbfirst, wl_noop, ecbdraw);
  760. X
  761. X    sprintf(statmsg, ECBLABEL1, ec_accept_level);
  762. X    gblset(&gblabel, statmsg);
  763. X
  764. X    ecbdraw(ecb);
  765. X    fflush(stdout);
  766. X
  767. X    ec_autoguess(ecbi, ec_accept_level);
  768. X    decode(ecbi->ciphertext, ecbi->plaintext, ecbi->perm);
  769. X
  770. X    sprintf(statmsg, ECBLABEL2, ec_accept_level);
  771. X    gblset(&gblabel, statmsg);
  772. X    ecbdraw(ecb);
  773. X
  774. X    return(NULL);
  775. X}
  776. X
  777. X
  778. X/*  (re) Draw the window.
  779. X */
  780. Xecbdraw(ecb)
  781. Xgwindow    *ecb;
  782. X{
  783. X    int            i;
  784. X    int            row, col;
  785. X    ecinfo        *ecbi;
  786. X
  787. X    ecbi = ((ecinfo *) ecb->wprivate);
  788. X    row = 1;
  789. X    col = 1;
  790. X
  791. X    for (i = 0 ; i < BLOCKSIZE ; i++)  {
  792. X        if (i%LINELEN == 0) {
  793. X            wl_setcur(ecb, gbspos2row(i), gbspos2col(i));
  794. X            }
  795. X        plnchars(1, char2sym(ecbi->plaintext[i]));
  796. X        }
  797. X
  798. X    for (i = gbspos2row(BLOCKSIZE) ; i <= GBHEIGHT ; i++) {
  799. X        wl_setcur(ecb, i, 1);
  800. X        plnchars(LINELEN, ' ');
  801. X        }
  802. X
  803. X    for (i = 1 ; i <= GBHEIGHT ; i++) {
  804. X        wl_setcur(ecb, i, LINELEN+1);
  805. X        plnchars(ecb->wwidth - LINELEN, ' ');
  806. X        }
  807. X
  808. X    wl_setcur(ecb, row, col);
  809. X}
  810. X
  811. X
  812. X/* First time cursor enters window.
  813. X */
  814. Xecbfirst(ecb, row, col)
  815. Xgwindow    *ecb;
  816. Xint            row, col;
  817. X{
  818. X    usrhelp(&user, ECBHELP);
  819. X    wl_setcur(ecb, row, col);
  820. X}
  821. X
  822. X
  823. X/* Enter the guess into the decryption block.
  824. X */
  825. Xecbenter(ecb)
  826. Xgwindow    *ecb;
  827. X{
  828. X    ecinfo        *ecbi;
  829. X
  830. X    ecbi = ((ecinfo *) ecb->wprivate);
  831. X    dbsmerge(&dbstore, ecbi->perm);
  832. X    wl_rcursor(ecb);
  833. X}
  834. X
  835. X
  836. X/* Undo the last guess.
  837. X */
  838. Xecbundo(ecb)
  839. Xgwindow    *ecb;
  840. X{
  841. X    ecinfo        *ecbi;
  842. X
  843. X    ecbi = ((ecinfo *) ecb->wprivate);
  844. X    dbsundo(&dbstore);
  845. X    wl_rcursor(ecb);
  846. X}
  847. X
  848. X
  849. X
  850. X
  851. X/* Dump plaintext chars onto stream.
  852. X */
  853. Xec_dplain(out, eci)
  854. XFILE    *out;
  855. Xecinfo    *eci;
  856. X{
  857. X    int        i,c;
  858. X    int        *pbuf;
  859. X
  860. X    pbuf = &eci->plaintext[0];
  861. X    for (i = 0 ; i < BLOCKSIZE ; i++) {
  862. X        c = *pbuf++;
  863. X        if (i % 20 == 0)  fprintf(out,"\n");
  864. X        if (c != NONE)
  865. X            write_char(out, c);
  866. X        else
  867. X            write_char(out, '.');
  868. X        }
  869. X    fprintf(out,"\n");
  870. X}
  871. X
  872. X
  873. X/* Dump shifted cipher chars onto stream.
  874. X */
  875. Xec_dscipher(out, eci)
  876. XFILE    *out;
  877. Xecinfo    *eci;
  878. X{
  879. X    int        i,c;
  880. X    int        *pbuf;
  881. X
  882. X    pbuf = &eci->scipher[0];
  883. X    for (i = 0 ; i < BLOCKSIZE ; i++) {
  884. X        c = *pbuf++;
  885. X        if (i++ % 20 == 0)  fprintf(out,"\n");
  886. X        if (c != NONE)
  887. X            write_char(out, c);
  888. X        else
  889. X            write_char(out, '.');
  890. X        }
  891. X    fprintf(out,"\n");
  892. X}
  893. X
  894. X
  895. X/* Dump table of next pointers onto a stream.
  896. X */
  897. Xec_dnext(out, eci)
  898. XFILE    *out;
  899. Xecinfo    *eci;
  900. X{
  901. X    writeperm(out, &(eci->next[0]));
  902. X}
  903. X
  904. X
  905. X/* Dump size table onto a stream.
  906. X */
  907. Xec_dsizetab(out, eci)
  908. XFILE    *out;
  909. Xecinfo    *eci;
  910. X{
  911. X    int        i;
  912. X
  913. X    fprintf(out, "\nThere are %d classes longer than 1 character.\n",
  914. X            eci->sizelast);
  915. X    for (i = 0 ; i < eci->sizelast ; i++)  {
  916. X        fprintf(out, "Size: %d,  First member: %d.\n",
  917. X                eci->sizelist[i].size, eci->sizelist[i].firstpos);
  918. X        }
  919. X}
  920. X
  921. X
  922. X/* Dump our permutation onto a stream.
  923. X */
  924. Xec_dperm(out, eci)
  925. XFILE    *out;
  926. Xecinfo    *eci;
  927. X{
  928. X    writeperm(out, &(eci->perm[0]));
  929. X}
  930. X
  931. X
  932. X/* Dump the permutation map onto a stream.
  933. X */
  934. Xec_dpmap(out, eci)
  935. XFILE    *out;
  936. Xecinfo    *eci;
  937. X{
  938. X    writeperm(out, &(eci->permmap[0]));
  939. X}
  940. X
  941. X
  942. X
  943. X/* Update ecbi to reflect the automatic guesses.
  944. X */
  945. Xec_autoguess(ecbi, alevel)
  946. Xecinfo    *ecbi;
  947. Xfloat    alevel;
  948. X{    int        i, c;
  949. X    int        classpos;
  950. X    int        x, y;
  951. X
  952. X    for (i = 0 ; i < ecbi->sizelast ; i++)  {
  953. X        classpos = ecbi->sizelist[i].firstpos;
  954. X        c = ec_best(ecbi, classpos, alevel);
  955. X        if (c != NONE) {
  956. X            x = ecbi->scipher[classpos];
  957. X            y = MODMASK & (c + classpos);
  958. X            if (!perm_conflict(ecbi->perm, x, y)) {
  959. X                ecbi->perm[x] = y;
  960. X                ecbi->perm[y] = x;
  961. X                }
  962. X#if DEBUG
  963. X            else {
  964. X                printf("ec_autoguess: Best guess conflicts");
  965. X                printf(" with an accepted.\n");
  966. X                }
  967. X#endif
  968. X            }
  969. X        }
  970. X}
  971. X
  972. X
  973. X/* Score a single equivalence class.
  974. X * Bigger scores are better scores.  They range from 0 to 1.
  975. X * A score of zero means the choice is not possible.
  976. X */
  977. Xfloat    ec_cscore(eci, firstpos, plainchar)
  978. Xecinfo    *eci;
  979. Xint        firstpos;
  980. Xint        plainchar;
  981. X{
  982. X    extern    float    logvar;
  983. X    float    score;
  984. X    int        pvec[BLOCKSIZE+1];
  985. X    int        ccount;
  986. X    char    str[BLOCKSIZE+1];
  987. X
  988. X
  989. X    if (decode_class(eci, firstpos, plainchar, pvec) == ERROR)  {
  990. X        return(0.0);
  991. X        }
  992. X
  993. X    score = pvec_1score(pvec);
  994. X    if (score < 0.0)  return(0.0);
  995. X    score = exp(-(score * score) / 2.0);
  996. X    for (ccount = 0 ; pvec[ccount] != NONE ; ccount++);
  997. X    score = score / sqrt(2*PI*logvar/ccount);
  998. X
  999. X#if DEBUG
  1000. X    if (score > MIN_SHOW_SCORE) {
  1001. X        pvec2str(str, pvec);
  1002. X        printf("Derived characters are '%s", str);
  1003. X        printf("', their score is %7.4f\n", score);
  1004. X        }
  1005. X#endif
  1006. X    return(score);
  1007. X}
  1008. X
  1009. X
  1010. X/* Select best plaintext value for a ciphertext equiv class.
  1011. X * The class is identified by the position in the block of one
  1012. X * of the characters in the class.  The plaintext value for
  1013. X * an entire class can be specified by the plaintext value of
  1014. X * one of its members.  This routine returns the best plaintext
  1015. X * value for the ciphertext character at position firstpos.
  1016. X * If there is not a clear best value, NONE is returned.
  1017. X */
  1018. Xint    ec_best(eci, firstpos, alevel)
  1019. Xecinfo    *eci;
  1020. Xint        firstpos;
  1021. Xfloat    alevel;
  1022. X{
  1023. X    float    total_score, score;
  1024. X    float    best_score;
  1025. X    int        best_char;
  1026. X    int        c;
  1027. X    int        x,y;
  1028. X    float    count;
  1029. X
  1030. X#if DEBUG
  1031. X    int        pvec[BLOCKSIZE+1];
  1032. X    char    str[BLOCKSIZE+1];
  1033. X
  1034. X    printf("\n");
  1035. X    printf("The first position of this class is %d.\n", firstpos);
  1036. X#endif
  1037. X    total_score = 0.0;
  1038. X    best_score = 0.0;
  1039. X    count = 0.0;
  1040. X    best_char = NONE;
  1041. X
  1042. X    for (c = 0 ; c <= MAXCHAR  ; c++)  {
  1043. X        score = ec_cscore(eci, firstpos, c);
  1044. X        if (score > 0.0)  {
  1045. X            count += 1.0;
  1046. X            total_score += score;
  1047. X            }
  1048. X        if (score > best_score) {
  1049. X            best_score = score;
  1050. X            best_char = c;
  1051. X            }
  1052. X        }
  1053. X
  1054. X#if DEBUG
  1055. X    printf("Total score is %7.4f", total_score);
  1056. X    printf(".  Count is %4.0f.\n", count);
  1057. X#endif
  1058. X    if (total_score == 0.0  ||  count == 0.0  ||  best_char == NONE) {
  1059. X#if DEBUG
  1060. X        printf("NO GUESSES\n");
  1061. X#endif
  1062. X        return(NONE);
  1063. X        }
  1064. X#if DEBUG
  1065. X    printf("Best score is %7.4f", best_score);
  1066. X    printf(", which is %7.4f fraction of total", best_score/total_score);
  1067. X    printf(".\n");
  1068. X
  1069. X    decode_class(eci, firstpos, best_char, pvec);
  1070. X    pvec2str(str, pvec);
  1071. X    printf("The best chars are '%s.\n", str);
  1072. X#endif
  1073. X
  1074. X    if (best_score  >  alevel * (total_score - best_score)) {
  1075. X        return(best_char);
  1076. X        }
  1077. X    else {
  1078. X        return(NONE);
  1079. X        }
  1080. X}
  1081. X
  1082. X
  1083. X/* Fill in equiv class info from given ciphertext block
  1084. X * and permutation.
  1085. X */
  1086. Xec_init(cipher, perm, eci)
  1087. Xchar    cipher[];
  1088. Xint        perm[];
  1089. Xecinfo    *eci;
  1090. X{
  1091. X    int        i,j;
  1092. X    int        lastmember;
  1093. X    int        firstpos, size;
  1094. X
  1095. X    eci->sizelast = 0;
  1096. X    eci->sizemin = 2;
  1097. X    for (i = 0 ; i < BLOCKSIZE ; i++)  {
  1098. X        eci->ciphertext[i] = cipher[i];
  1099. X        eci->scipher[i] = (cipher[i] + i)&MODMASK;
  1100. X        eci->perm[i] = perm[i];
  1101. X        eci->permmap[i] = NONE;
  1102. X        }
  1103. X    decode(eci->ciphertext, eci->plaintext, eci->perm);
  1104. X
  1105. X
  1106. X    /* The permmap points to the most recent member we have seen */
  1107. X    /* of each known class, or a NONE.  Ptrs are array indexes. */
  1108. X    for (i = BLOCKSIZE-1 ; i >= 0 ; i--) {
  1109. X        eci->next[i] = i;
  1110. X        if ((lastmember = eci->permmap[eci->scipher[i]]) != NONE) {
  1111. X            eci->next[i] = eci->next[lastmember];
  1112. X            eci->next[lastmember] = i;
  1113. X            }
  1114. X        eci->permmap[eci->scipher[i]] = i;
  1115. X        }
  1116. X
  1117. X    for (i = 0 ; i < BLOCKSIZE ; i++)  {
  1118. X        firstpos = eci->permmap[i];
  1119. X        if (firstpos != NONE)  {
  1120. X            size = ec_compsize(eci, firstpos);
  1121. X            ec_addsize(eci, size, firstpos);
  1122. X            }
  1123. X        }
  1124. X}
  1125. X
  1126. X
  1127. X/* Add an entry to the size list.
  1128. X * Implementation:  Find the first slot before sizelast+1 that
  1129. X * has a size less than the size arg.  Shuffle down the list
  1130. X * to create a hole and insert the new entry.
  1131. X */
  1132. Xec_addsize(eci, size, firstmember)
  1133. Xregister    ecinfo    *eci;
  1134. Xint        size;
  1135. Xint        firstmember;
  1136. X{
  1137. X    int        k;        /* Slot where new entry will go. */
  1138. X    int        i;
  1139. X    ecsize    sizeinfo;
  1140. X
  1141. X    if (size < eci->sizemin) return;
  1142. X
  1143. X    sizeinfo.size = size;
  1144. X    sizeinfo.firstpos = firstmember;
  1145. X    for (k = 0 ; k < eci->sizelast ; k++)  {
  1146. X        if (eci->sizelist[k].size < size)  break;
  1147. X        }
  1148. X    if (k >= SZMAX) return;
  1149. X
  1150. X    for (i = eci->sizelast ; i > k ; i--)  {
  1151. X        eci->sizelist[i] = eci->sizelist[i-1];
  1152. X        }
  1153. X    eci->sizelast++;
  1154. X
  1155. X    eci->sizelist[k] = sizeinfo;
  1156. X}
  1157. X
  1158. X
  1159. X/* Compute the size of a clas given a pointer to one of its members.
  1160. X */
  1161. Xint    ec_compsize(eci, member)
  1162. Xecinfo    *eci;
  1163. Xint        member;
  1164. X{
  1165. X    int        size;
  1166. X    int        position;
  1167. X    int        firstflag;
  1168. X
  1169. X    size = 0;
  1170. X    for_pos_in_class(position, member) {
  1171. X        size++;
  1172. X        }
  1173. X    return(size);
  1174. X}
  1175. END_OF_eclass.c
  1176. if test 9192 -ne `wc -c <eclass.c`; then
  1177.     echo shar: \"eclass.c\" unpacked with wrong size!
  1178. fi
  1179. # end of overwriting check
  1180. fi
  1181. if test -f knit.c -a "${1}" != "-c" ; then 
  1182.   echo shar: Will not over-write existing file \"knit.c\"
  1183. else
  1184. echo shar: Extracting \"knit.c\" \(10707 characters\)
  1185. sed "s/^X//" >knit.c <<'END_OF_knit.c'
  1186. X/*
  1187. X * Use serveral mostly solved blocks to solve the knitting equation
  1188. X * and deduce the rotor and reflector wirings.
  1189. X *
  1190. X * Robert W. Baldwin, December 1984.
  1191. X */
  1192. X
  1193. X
  1194. X#include    <stdio.h>
  1195. X#include    "window.h"
  1196. X#include    "terminal.h"
  1197. X#include    "layout.h"
  1198. X#include    "specs.h"
  1199. X
  1200. X
  1201. Xextern    char    gcbuf[];        /* All guess displays use same buffers. */
  1202. Xextern    int        gpbuf[];
  1203. Xextern    int        gperm[];
  1204. X
  1205. X
  1206. X#define KNTHELP    "F2 = next guess, F3 = enter guess, ^G = Undo enter."
  1207. X#define STARTMSG "Knitting from %d to %d.   Known Zee: %d of 256."
  1208. X#define GUESSMSG "guesscount = %d, xi=%d, yi=%d.   Known Zee: %d of 256."
  1209. X#define UNDOMSG  "Undone.  Current known Zee: %d of 256"
  1210. X#define    BIG        1000        /* Size of try stack in kntadvance(). */
  1211. X
  1212. X
  1213. X/* Pack and unpack two bytes into an integer. */
  1214. X#define pack(x,y)        (((x&0377)<<8) + y)
  1215. X#define unpack(x,y,v)    tmpv = v; x = ((tmpv>>8)&0377);  y = (tmpv&0377);
  1216. X
  1217. X
  1218. X/* Keystroke handler table. */
  1219. X
  1220. Xextern    int    kntadvance();
  1221. Xextern    kntundo();
  1222. Xextern    kntnextg();
  1223. Xextern    kntenter();
  1224. X
  1225. Xkeyer    kntktab[] = {
  1226. X        {CNEXTGUESS, kntnextg},
  1227. X        {CACCEPT, kntenter},
  1228. X        {CUNDO, kntundo},
  1229. X        {CGO_UP, jogup},
  1230. X        {CGO_DOWN, jogdown},
  1231. X        {CGO_LEFT, jogleft},
  1232. X        {CGO_RIGHT, jogright},
  1233. X        {0, NULL},
  1234. X};
  1235. X
  1236. X
  1237. X
  1238. X/* Private data structure for guess blocks. */
  1239. X
  1240. X#define    kntinfo        struct    xkntinfo
  1241. Xstruct    xkntinfo    {
  1242. X        char    *cbuf;        /* The cipher block. */
  1243. X        int        *pbuf;        /* The derived guess plaintext, -1 = none. */
  1244. X        int        *perm;        /* Permutation of block highbnum+1. */
  1245. X        int        xindex;        /* Starting position of next x guess. */
  1246. X        int        yindex;        /* Starting position of next y guess. */
  1247. X        int        *zee;        /* Knitting matrix. */
  1248. X        int        *zeeinv;    /* Its inverse. */
  1249. X        int        *ustkp;        /* Undo stack pointer. */
  1250. X        int        *savedustkp;    /* Undo stack pointer. */
  1251. X        int        *undostk;    /* Undo stack. */
  1252. X        int        lowbnum;    /* Block number of lowest source. */
  1253. X        int        highbnum;    /* Block number of highest source. */
  1254. X        int        min_show;    /* Smallest count to show. */
  1255. X        };
  1256. X
  1257. X
  1258. X/* Private buffers. */
  1259. Xint        kzee[BLOCKSIZE+1];
  1260. Xint        kzeeinv[BLOCKSIZE+1];
  1261. Xint        kustk[BLOCKSIZE+1];
  1262. X
  1263. Xkntinfo    kntprivate;
  1264. X
  1265. Xint        kntinit    = FALSE;
  1266. X
  1267. X
  1268. Xextern    kntdraw(), kntfirst();        /* Defined below. */
  1269. X
  1270. X
  1271. X/* This routine is called by the user command to clear the zee matrix.
  1272. X */
  1273. Xchar    *clearzee(str)
  1274. Xchar    *str;        /* Command line */
  1275. X{
  1276. X    int        i;
  1277. X    kntinfo    *knti;
  1278. X
  1279. X    knti = &kntprivate;
  1280. X    initknt();
  1281. X    kntclrzee(knti);
  1282. X
  1283. X    if (&kntprivate == ((kntinfo *) gbstore.wprivate)) {
  1284. X        for (i = 0 ; i < BLOCKSIZE ; i++)  {
  1285. X            knti->perm[i] = -1;
  1286. X            }
  1287. X        decode(knti->cbuf, knti->pbuf, knti->perm);
  1288. X        sprintf(statmsg, GUESSMSG,
  1289. X                0, knti->xindex, knti->yindex, zeecount(knti));
  1290. X        gblset(&gblabel, statmsg);
  1291. X        wl_draw(&gbstore);
  1292. X        }
  1293. X
  1294. X    wl_rcursor(&user);
  1295. X    return(NULL);
  1296. X}
  1297. X
  1298. X
  1299. X
  1300. X/* This routine is called to set up the guess block window
  1301. X * to be used for guessing the zee matrix.
  1302. X * It can be directly invoked by the command interpreter.
  1303. X * Set up dbstore to show the block after the last block
  1304. X * the the user says to consider complete.
  1305. X */
  1306. Xchar    *kntguess(str)
  1307. Xchar    *str;        /* Command line */
  1308. X{
  1309. X    int        i;
  1310. X    int        from,to;
  1311. X    gwindow    *knt;
  1312. X    kntinfo    *knti;
  1313. X
  1314. X    knt = &gbstore;
  1315. X    knti = &kntprivate;
  1316. X    initknt();
  1317. X
  1318. X    if (!kntinit) {
  1319. X        kntinit = TRUE;
  1320. X        kntclrzee(knti);
  1321. X        }
  1322. X
  1323. X    for (i = 0 ; i < BLOCKSIZE ; i++)  {
  1324. X        knti->perm[i] = -1;
  1325. X        }
  1326. X
  1327. X    from = to = 0;
  1328. X    if ((i = sscanf(str,"%*[^:]: %d %*[^:]: %d %*[^:]: %d",
  1329. X                    &from, &to, &knti->min_show)) != 3) {
  1330. X        return("Could not parse all arguments.");
  1331. X        }
  1332. X    else {
  1333. X        if (to <= from)
  1334. X            return("To: must be less than From:");
  1335. X        }
  1336. X    
  1337. X    dbssetblk(&dbstore, to+1);
  1338. X    if (!fillcbuf(to+1, knti->cbuf)) {
  1339. X        return("Bad to: value");
  1340. X        }
  1341. X    decode(knti->cbuf, knti->pbuf, knti->perm);
  1342. X    knti->xindex = 0;
  1343. X    knti->yindex = 0;
  1344. X    knti->lowbnum = from;
  1345. X    knti->highbnum = to;
  1346. X
  1347. X    gbsswitch(knt,((char *) knti), kntktab, kntfirst, wl_noop, kntdraw);
  1348. X    sprintf(statmsg, STARTMSG, from, to, zeecount(knti));
  1349. X    gblset(&gblabel, statmsg);
  1350. X    kntdraw(knt);
  1351. X
  1352. X    wl_setcur(knt, 1, 1);
  1353. X    return(NULL);
  1354. X}
  1355. X
  1356. X
  1357. X
  1358. X/* Clear the zee permutation and update any display info.
  1359. X */
  1360. Xkntclrzee(knti)
  1361. Xkntinfo    *knti;
  1362. X{
  1363. X    int        i;
  1364. X
  1365. X    for (i = 0 ; i < BLOCKSIZE ; i++)  {
  1366. X        knti->zee[i] = -1;
  1367. X        knti->zeeinv[i] = -1;
  1368. X        }
  1369. X}
  1370. X
  1371. X
  1372. X/* Compute the next successful guess of a wiring of ZEE.
  1373. X * Show it to the user for acceptance/rejection.
  1374. X */
  1375. Xkntnextg(knt)
  1376. Xgwindow    *knt;
  1377. X{
  1378. X    int        guesscnt;
  1379. X    kntinfo    *knti;
  1380. X    knti = ((kntinfo *) knt->wprivate);
  1381. X
  1382. X    kntclrlast(knti);
  1383. X    while (TRUE) {
  1384. X        guesscnt = kntadvance(knti);
  1385. X        if ((guesscnt == 0) || (guesscnt >= knti->min_show))  break;
  1386. X        kntclrlast(knti);
  1387. X        }
  1388. X    if (guesscnt == 0)  {
  1389. X        gblset(&gblabel, "No more guesses");
  1390. X        return;
  1391. X        }
  1392. X    decode(knti->cbuf, knti->pbuf, knti->perm);
  1393. X
  1394. X    sprintf(statmsg, GUESSMSG,
  1395. X            guesscnt, knti->xindex, knti->yindex, zeecount(knti));
  1396. X    gblset(&gblabel, statmsg);
  1397. X    kntdraw(knt);
  1398. X}
  1399. X
  1400. X
  1401. X
  1402. X/* Clear last guess in zee, zeeinv, perm.
  1403. X * Note that perm only holds the results of the last guess.
  1404. X */
  1405. Xkntclrlast(knti)
  1406. Xkntinfo    *knti;
  1407. X{
  1408. X    int        tmpv;    /* For unpack. */
  1409. X    int        x,y;
  1410. X    int        i;
  1411. X
  1412. X    while (knti->ustkp > knti->undostk)  {
  1413. X        unpack(x, y, *(--(knti->ustkp)));
  1414. X        knti->zee[x] = -1;
  1415. X        knti->zeeinv[y] = -1;
  1416. X        }
  1417. X    knti->ustkp = knti->savedustkp = knti->undostk;
  1418. X        
  1419. X    for (i = 0 ; i < BLOCKSIZE ; i++) {
  1420. X        knti->perm[i] = -1;
  1421. X        }
  1422. X}
  1423. X
  1424. X
  1425. X
  1426. X/* Advance to the next acceptable guess at a wiring for Zee.
  1427. X * This modifies zee, zeeinv, and perm.  Perm only contains the
  1428. X * info derived from this guess, while zee and zeeinv accumulate
  1429. X * information from all preceeding accepted guesses.
  1430. X * Returns the number of guesses that we derived from the initial one.
  1431. X * If out of acceptable guesses, returns 0.
  1432. X * Perm must be cleared before calling this.
  1433. X */
  1434. Xint    kntadvance(knti)
  1435. Xkntinfo    *knti;
  1436. X{
  1437. X    int        guesscount;
  1438. X    int        i;
  1439. X    int        tmpv;        /* For unpack. */
  1440. X    int        x,y;
  1441. X    int        tx,ty;
  1442. X    int        u,v;
  1443. X    int        tu,tv;
  1444. X    int        *a2;        /* The permutation as in u = A2 x */
  1445. X    int        *a1;        /* The permutation as in v = A1 y */
  1446. X    int        *propp;        /* Temp for undo stack propagation. */
  1447. X    int        *highperm;    /* Perm used to derive next perm. */
  1448. X    int        trycount;    /* Size of trystk. */
  1449. X    int        *tstkp;        /* Stack of guesses to check. */
  1450. X    int        trystk[BIG];
  1451. X
  1452. X/* kntadvance(knti)
  1453. X */
  1454. X    guesscount = 0;        /* In case loop body never executes. */
  1455. X
  1456. X    if (knti->xindex >= BLOCKSIZE)  return(0);
  1457. X    if (knti->yindex >= BLOCKSIZE)  {
  1458. X        knti->yindex = 0;
  1459. X        knti->xindex++;
  1460. X        }
  1461. X
  1462. X    for (x = knti->xindex ; x < BLOCKSIZE ; x++) {
  1463. X        if (knti->zee[x] != -1)  {
  1464. X            knti->yindex = 0;
  1465. X            continue;
  1466. X            }
  1467. X        for (y = knti->yindex ; y < BLOCKSIZE ; y++) {
  1468. X            if (knti->zeeinv[y] != -1)  continue;
  1469. X            guesscount = 0;
  1470. X            tstkp = trystk;                    /* Assume ustkp == undostk. */
  1471. X            trycount = 0;
  1472. X            *(tstkp++) = pack(x,y);
  1473. X            trycount++;
  1474. X
  1475. X            while (tstkp > trystk) {
  1476. X                unpack(tx, ty, *(--tstkp));
  1477. X                trycount--;
  1478. X                if (knti->zee[tx] == -1 && knti->zeeinv[ty] == -1) {
  1479. X                    knti->zee[tx] = ty;
  1480. X                    knti->zeeinv[ty] = tx;
  1481. X                    *((knti->ustkp)++) = pack(tx,ty);
  1482. X                    guesscount++;
  1483. X                    for (i = knti->lowbnum ; (i+1) <= knti->highbnum ; i++) {
  1484. X                        a1 = refperm(i);
  1485. X                        a2 = refperm(i+1);
  1486. X                        tu = a2[tx];
  1487. X                        tv = a1[ty];
  1488. X                        if (tu != -1 && tv != -1 && trycount < BIG) {
  1489. X                            *(tstkp++) = pack(tu, tv);
  1490. X                            trycount++;
  1491. X                            }
  1492. X                        }
  1493. X                    }
  1494. X                else if (knti->zee[tx] != ty
  1495. X                      || knti->zeeinv[ty] != tx) {        /* If conflict. */
  1496. X                        while (knti->ustkp > knti->undostk)  {
  1497. X                            unpack(tx, ty, *(--(knti->ustkp)));
  1498. X                            knti->zee[tx] = -1;
  1499. X                            knti->zeeinv[ty] = -1;
  1500. X                            guesscount--;
  1501. X                            }
  1502. X                        knti->ustkp = knti->undostk;
  1503. X                        goto nxtguess;
  1504. X                      }
  1505. X                else continue;        /* Already know about it. */
  1506. X                }
  1507. X
  1508. X            knti->xindex = x;        /* Zee[x] = y was a good guess. */
  1509. X            knti->yindex = y+1;
  1510. X            propp = knti->ustkp;
  1511. X            highperm = refperm(knti->highbnum);
  1512. X            while (propp > knti->undostk) {  /* Update perm. */
  1513. X                unpack(tx, ty, *(--propp));
  1514. X                v = highperm[ty];
  1515. X                if (v != -1  &&  (tmpv = knti->zeeinv[v]) != -1)  {
  1516. X                    knti->perm[tx] = tmpv;
  1517. X                    knti->perm[tmpv] = tx;
  1518. X                    }
  1519. X                }
  1520. X            return (guesscount);
  1521. X            nxtguess: ;
  1522. X            }
  1523. X        knti->yindex = 0;
  1524. X        }
  1525. X
  1526. X    knti->yindex = 0;
  1527. X    knti->xindex = 0;
  1528. X    return(guesscount);
  1529. X}
  1530. X             
  1531. X
  1532. X/* Enter our current guess into the decryption block.
  1533. X * Clear out the undo stack.
  1534. X */
  1535. Xkntenter(knt)
  1536. Xgwindow    *knt;
  1537. X{
  1538. X    kntinfo    *knti;
  1539. X
  1540. X    knti = ((kntinfo *) knt->wprivate);
  1541. X    knti->savedustkp = knti->ustkp;        /* If we change our mind. */
  1542. X    knti->ustkp = knti->undostk;
  1543. X    if (knti->highbnum+1 != dbsgetblk(&dbstore))
  1544. X        dbssetblk(&dbstore, knti->highbnum+1);
  1545. X    dbsmerge(&dbstore, knti->perm);
  1546. X    wl_rcursor(knt);
  1547. X}
  1548. X
  1549. X
  1550. X/* Undo the last guess.
  1551. X */
  1552. Xkntundo(knt)
  1553. Xgwindow    *knt;
  1554. X{
  1555. X    kntinfo    *knti;
  1556. X
  1557. X    knti = ((kntinfo *) knt->wprivate);
  1558. X    knti->ustkp = knti->savedustkp;
  1559. X    kntclrlast();
  1560. X    dbsundo(&dbstore);
  1561. X
  1562. X    sprintf(statmsg, UNDOMSG, zeecount(knti));
  1563. X    gblset(&gblabel, statmsg);
  1564. X    wl_rcursor(knt);
  1565. X}
  1566. X
  1567. X
  1568. X/* Behavior when first enter the window.
  1569. X * Put up a help message.
  1570. X * Accept the cursor where it is.
  1571. X */
  1572. Xkntfirst(knt, row, col)
  1573. Xgwindow    *knt;
  1574. Xint        row,col;    /* Current coordinates. */
  1575. X{
  1576. X    usrhelp(&user, KNTHELP);
  1577. X    wl_setcur(knt, row, col);
  1578. X}
  1579. X
  1580. X
  1581. X
  1582. X/* (re)Draw the window.
  1583. X */
  1584. Xkntdraw(knt)
  1585. Xgwindow    *knt;
  1586. X{
  1587. X    int            i;
  1588. X    int            row, col;        /* Original row and column. */
  1589. X    kntinfo        *knti;
  1590. X
  1591. X    knti = ((kntinfo *) knt->wprivate);
  1592. X    row = knt->wcur_row;
  1593. X    col = knt->wcur_col;
  1594. X
  1595. X    for (i = 0 ; i < BLOCKSIZE ; i++)  {
  1596. X        if (i%LINELEN == 0) {
  1597. X            wl_setcur(knt, gbspos2row(i), gbspos2col(i));
  1598. X            }
  1599. X        plnchars(1, char2sym(knti->pbuf[i]));
  1600. X        }
  1601. X
  1602. X    for (i = gbspos2row(BLOCKSIZE) ; i <= GBHEIGHT ; i++) {
  1603. X        wl_setcur(knt, i, 1);
  1604. X        plnchars(LINELEN, ' ');
  1605. X        }
  1606. X
  1607. X    for (i = 1 ; i <= GBHEIGHT ; i++) {
  1608. X        wl_setcur(knt, i, LINELEN+1);
  1609. X        plnchars(knt->wwidth - LINELEN, ' ');
  1610. X        }
  1611. X
  1612. X    wl_setcur(knt, row, col);
  1613. X}
  1614. X
  1615. X
  1616. X/* Return number of known wires in Zee.
  1617. X * Max is 256.
  1618. X */
  1619. Xint    zeecount(knti)
  1620. Xkntinfo    *knti;
  1621. X{
  1622. X    return(permcount(knti->zee));
  1623. X}
  1624. X
  1625. X
  1626. X/* Store Zee permutation on a file.
  1627. X */
  1628. Xstorezee(fd)
  1629. XFILE    *fd;
  1630. X{
  1631. X    writeperm(fd, kzee);
  1632. X}
  1633. X
  1634. X
  1635. X/* Load the Zee permutation from a file.
  1636. X * Update display if necessary.
  1637. X */
  1638. Xloadzee(fd)
  1639. XFILE    *fd;
  1640. X{
  1641. X    int        i;
  1642. X    kntinfo    *knti;
  1643. X
  1644. X    knti = &kntprivate;
  1645. X    initknt();
  1646. X    kntinit = TRUE;
  1647. X    kntclrzee(knti);        /* Clear zeeinv */
  1648. X
  1649. X    readperm(fd, kzee);    
  1650. X    for (i = 0 ; i < BLOCKSIZE ; i++) {
  1651. X        if (kzee[i] != -1)  {kzeeinv[kzee[i]] = i;}
  1652. X        }
  1653. X
  1654. X    if (knti == ((kntinfo *) gbstore.wprivate)) {
  1655. X        for (i = 0 ; i < BLOCKSIZE ; i++)  {
  1656. X            knti->perm[i] = -1;
  1657. X            }
  1658. X        decode(knti->cbuf, knti->pbuf, knti->perm);
  1659. X        sprintf(statmsg, GUESSMSG,
  1660. X                0, knti->xindex, knti->yindex, zeecount(knti));
  1661. X        gblset(&gblabel, statmsg);
  1662. X        wl_draw(&gbstore);
  1663. X        wl_setcur(&gbstore, 1, 1);
  1664. X        }
  1665. X}
  1666. X
  1667. X
  1668. X/* Set up all the pointers in kntprivate.
  1669. X */
  1670. Xinitknt()
  1671. X{
  1672. X    int        i;
  1673. X    gwindow    *knt;
  1674. X    kntinfo    *knti;
  1675. X
  1676. X    knt = &gbstore;
  1677. X    knti = &kntprivate;
  1678. X
  1679. X    knti->zee = kzee;
  1680. X    knti->zeeinv = kzeeinv;
  1681. X
  1682. X    knti->cbuf = gcbuf;
  1683. X    knti->pbuf = gpbuf;
  1684. X    knti->perm = gperm;
  1685. X
  1686. X    knti->undostk = kustk;
  1687. X    knti->ustkp = knti->savedustkp = knti->undostk;
  1688. X}
  1689. END_OF_knit.c
  1690. if test 10707 -ne `wc -c <knit.c`; then
  1691.     echo shar: \"knit.c\" unpacked with wrong size!
  1692. fi
  1693. # end of overwriting check
  1694. fi
  1695. if test -f zeecode.perm -a "${1}" != "-c" ; then 
  1696.   echo shar: Will not over-write existing file \"zeecode.perm\"
  1697. else
  1698. echo shar: Extracting \"zeecode.perm\" \(11550 characters\)
  1699. sed "s/^X//" >zeecode.perm <<'END_OF_zeecode.perm'
  1700. X 28 146 116 150 159  64 172 249 200 232 
  1701. X 90 149  63 239 238  95  49 254 143   8 
  1702. X191 231 123 117 243 210 179 186 119  17 
  1703. X107  46 174 203  21  12  97  53 135  71 
  1704. X 52  78 204  31 220  77 211  24 225 121 
  1705. X 74 228 202 171  11  81  67  69 141 213 
  1706. X 66  94 195 217  29 154   3  15  59  76 
  1707. X205 155  25  93 209 160 212  36 173  68 
  1708. X221 193 176 196   4 138  99 222  70  57 
  1709. X  7 252  41  43  62  79  48  61 145  38 
  1710. X 20 216 166 208  40 187   0 153   5 137 
  1711. X 55 130 241   6 207 128 227 190 142 125 
  1712. X177  75 226 105   2 175  51 120  96  13 
  1713. X139  47 127 246 248  18  44  16 136 167 
  1714. X132 113 151  98 244 114 182 198 201 189 
  1715. X144  22 140 122 109  83 131 180 253  58 
  1716. X162  50 250 134  37   1  35 242  23 214 
  1717. X194 112 157 223 165 233 156 161 188 104 
  1718. X124 103  54 234  89  80 101  26  19  85 
  1719. X192 147 181  65 199   9 247 245 129  60 
  1720. X169 102  32  88 224 106 235  45 236  84 
  1721. X255  92 178 215 230  33 115 185  27  39 
  1722. X237 251  30  14 163 126 219  87 206  73 
  1723. X158  56 110 168  91 152 197 108 133 148 
  1724. X 72 118 184 240 100 164 111 170 183 229 
  1725. X 42  10 218  82  86  34 
  1726. X 96 114 124 223  97  19  10  13  43  44 
  1727. X  6  38 231   7 200 207 179 134 133   5 
  1728. X100 230  48 160 152  93 162 168 191 127 
  1729. X 65 103 183  90 252 193 243 242  11 180 
  1730. X 87 173 154   8   9  99 112  58  22 108 
  1731. X199  95  77  66 163  62 128 190  47  79 
  1732. X215 109  55 245  73  30  53 178 214  82 
  1733. X201 138 206  64 240 182 228  52 140  59 
  1734. X197 248  69 203 175 111 137  40 153 139 
  1735. X 33 195 212  25 217  51   0   4 251  45 
  1736. X 20 122 148  31 227 234 167 202  49  61 
  1737. X219  85  46 246   1 135 142 254 211 249 
  1738. X144 255 101 218   2 150 186  29  56 169 
  1739. X185 247 164  18  17 115 250  86  71  89 
  1740. X 78 205 116 222 120 216 226 158 102 189 
  1741. X125 225  24  88  42 159 221 188 147 155 
  1742. X 23 210  26  54 132 232 184 106  27 129 
  1743. X236 196 253  41 204  84 238 235  67  16 
  1744. X 39 192  75  32 166 130 126 224 157 149 
  1745. X 57  28 181  35 241  91 171  80 208  50 
  1746. X 14  70 107  83 174 141  72  15 198 233 
  1747. X161 118  92 244  68  60 145  94 123 110 
  1748. X237 156 143   3 187 151 146 104  76 239 
  1749. X 21  12 165 209 105 177 170 220 176 229 
  1750. X 74 194  37  36 213  63 113 131  81 119 
  1751. X136  98  34 172 117 121 
  1752. X 20 122 118 119  71 229 158  28 223 174 
  1753. X215  -1 197 249  82 126 237  23  87  93 
  1754. X  0  35 252  17  77 177 137 225   7 163 
  1755. X 52 171  42 155 214  21  84  60 216  85 
  1756. X 45 152  32 181 220  40 241 235 142 210 
  1757. X243  69  30  83  99 134 212 253  70 144 
  1758. X 37  63 234  61 132 250 173 114  95  51 
  1759. X 58   4  73  72 175 168 211  24  92 169 
  1760. X176 166  14  53  36  39 207  18 148 117 
  1761. X129 255  78  19 110  68 151 154 101  54 
  1762. X244  98 242 147 227 204 128 203 188 254 
  1763. X 94 217 170 251  67 231  -1  89   2   3 
  1764. X206 146   1 183  -1 209  15 150 106  90 
  1765. X184 159  64 141  55 238 195  26 162 205 
  1766. X245 133  48 221  59 165 121 103  88  -1 
  1767. X127  96  41 186  97  33 196  -1   6 131 
  1768. X187 194 138  29 167 145  81 164  75  79 
  1769. X112  31 178  66   9  74  80  25 172  -1 
  1770. X -1  43 224 123 130 236 153 160 108 246 
  1771. X192 230 190 222 161 136 156  12 200 213 
  1772. X198 239 248 107 105 139 120  86 247 125 
  1773. X 49  76  56 199  34  10  38 111 233  -1 
  1774. X 44 143 193   8 182  27 232 104 240   5 
  1775. X191 115 226 218  62  47 185  16 135 201 
  1776. X228  46 102  50 100 140 189 208 202  13 
  1777. X 65 113  22  57 109  91 
  1778. X 90  49  26 132 156 140 212 129 147 122 
  1779. X198  -1  97 148  38  79  25 154  80 173 
  1780. X214 216 248 184 161  16   2 107  66 168 
  1781. X 33 112 195  30 166 236  65 155  14  84 
  1782. X222 211 123  53 136  47  69  45 218   1 
  1783. X125 243 134  43  -1 102 145 126 238 194 
  1784. X 78 232 138 246 224  36  28 225 150  46 
  1785. X130 215 120 188 119 105 231 209  60  15 
  1786. X 18  87 185 176  39 160 182  81 159 158 
  1787. X  0 151 235 192 183 200 118  12 174  -1 
  1788. X106  -1  55 196 207  75 100  27 249 187 
  1789. X163 242  31 230 254 205 179 190  96  74 
  1790. X 72 233   9  42 241  50  57 228 142   7 
  1791. X 70 206   3 149  52 227  44 220  62 245 
  1792. X  5 221 128 186 244  56 204   8  13 133 
  1793. X 68  91 197 165  17  37   4 180  89  88 
  1794. X 85  24 193 110 199 153  34 201  29 255 
  1795. X177 247 226  19  98 252  83 170 237 116 
  1796. X157 191  86  94  23  82 143 109  73 219 
  1797. X117 181  93 162  59  32 103 152  10 164 
  1798. X 95 167 250 239 146 115 131 104 217  77 
  1799. X234  41   6 251  20  71  21 208  48 189 
  1800. X137 141  40 253  64  67 172 135 127 240 
  1801. X113  76  61 121 210  92  35 178  58 203 
  1802. X229 124 111  51 144 139  63 171  22 108 
  1803. X202 213 175 223 114 169 
  1804. X 60  42  26  79 203 204 122 237  15  97 
  1805. X106 238 133  33 159   8 165 145  27 191 
  1806. X192  69 250 117 126 183   2  18  50  65 
  1807. X218  57 143  13 101  36  35  93 116 213 
  1808. X163 199   1 171 109  74  92 177  56 175 
  1809. X 28 132 162 196  -1 227  48  31  80 221 
  1810. X  0 248 202 103 233  29 140  95 170  21 
  1811. X216 164 137 190  45 189 113 193 188   3 
  1812. X 58 160 155 181 176  94 186 104 111 225 
  1813. X198 125  46  37  85  67 252   9 231 223 
  1814. X169  34 255  63  87 154  10 174 152  44 
  1815. X201  88  -1  76 179 118  38  23 115 161 
  1816. X247 123   6 121 187  91  24 240 241 239 
  1817. X197 207  51  12 151 185 138  72 136 148 
  1818. X 66 214 234  32 150  17 254  -1 139 226 
  1819. X144 134 108 195 105  82 228 172 173  14 
  1820. X 81 119  52  40  71  16 208 246 242 100 
  1821. X 68  43 157 158 107  49  84  47 229 114 
  1822. X -1  83  -1  25 230 135  86 124  78  75 
  1823. X 73  19  20  77 245 153  53 130  90  41 
  1824. X210 110  62   4   5 244 211 131 166 219 
  1825. X200 206 220  39 141 222  70 253  30 209 
  1826. X212  59 215  99 232  89 149  55 156 178 
  1827. X184  98 224  64 142 236 235   7  11 129 
  1828. X127 128 168 249 205 194 167 120  61 243 
  1829. X 22  -1  96 217 146 102 
  1830. X161  17  99 150 223 175 172  24  25 204 
  1831. X147 122 181 198  54  56 125   1 202  67 
  1832. X188 143  49 168   7   8 145 254 177  98 
  1833. X 32 211  30  84  57 238 195  83 217 245 
  1834. X160 178 108  89  76  81 228 225 184  22 
  1835. X207 176  94  93  14  75  15  34 169 219 
  1836. X152 189 107 158 193 123  95  19  80 141 
  1837. X144 253 248 164 226  55  44 166 230 247 
  1838. X 68  45 209  37  33 138  -1 213 101  43 
  1839. X220 128 194  53  52  66 231 134  29   2 
  1840. X190  88 103 102 224 180 199  62  42 240 
  1841. X116 236 115 153 156 112 110 229 183 234 
  1842. X131 149  11  65 187  16 140 196  91 215 
  1843. X239 120 243 139  97 218 154 174  85 133 
  1844. X126  69 163  21  70  26 182  10 232 121 
  1845. X  3 162  60 113 136 192 114 171  63 185 
  1846. X 40   0 151 142  73 250  77 233  23  58 
  1847. X197 157   6  -1 137   5  51  28  41 227 
  1848. X105  12 146 118  48 159 255 124  20  61 
  1849. X100  -1 155  64  92  36 127 170  13 106 
  1850. X244 210  18 246   9 251 208  50 206  82 
  1851. X201  31 249  87 242 129 241  38 135  59 
  1852. X 90  -1 252   4 104  47  74 179  46 117 
  1853. X 78  96 148 167 119 237 111 235  35 130 
  1854. X109 216 214 132 200  39 203  79  72 212 
  1855. X165 205 222  71  27 186 
  1856. X120 146 232  66 217  81 113  76 144 239 
  1857. X 44  49 230 111 166  60 151 218  34  72 
  1858. X 80 128 193 249 140 148 116 210 183 165 
  1859. X 94  51 109 133  18 192 163  73 252 158 
  1860. X 61 214 195  46  10 102  43  90 131  11 
  1861. X122  31 135 172 153 207 188  58  57 227 
  1862. X 15  40  77  99 143 138   3 231 226 136 
  1863. X221 190  19  37 253 104   7  62 254 185 
  1864. X 20   5 126 132 173 189 124  91 150 255 
  1865. X 47  87 212 184  30 196 242 149 187  63 
  1866. X178 112  45 228  75 180 177 141 125  32 
  1867. X121  13 101   6 161 234  26 244 224 137 
  1868. X  0 110  50 157  86 108  82 156  21 147 
  1869. X238  48  83  33 240  52  69 119  65 175 
  1870. X 24 107 160  64   8 176   1 129  25  97 
  1871. X 88  16 225  54 243 164 127 123  39 200 
  1872. X142 114 174  36 155  29  14 169 233 167 
  1873. X211 216  53  84 162 139 145 106 100 204 
  1874. X105 201 223  28  93  79 203  98  56  85 
  1875. X 71 251  35  22 205  42  95 219 213 235 
  1876. X159 181 222 186 179 194 220  55 246 215 
  1877. X 27 170  92 198  41 209 171   4  17 197 
  1878. X206  70 202 182 118 152  68  59 103 245 
  1879. X 12  67   2 168 115 199 247 250 130   9 
  1880. X134 248  96 154 117 229 208 236 241  23 
  1881. X237 191  38  74  78  89 
  1882. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1883. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1884. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1885. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1886. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1887. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1888. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1889. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1890. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1891. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1892. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1893. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1894. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1895. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1896. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1897. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1898. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1899. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1900. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1901. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1902. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1903. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1904. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1905. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1906. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1907. X -1  -1  -1  -1  -1  -1 
  1908. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1909. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1910. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1911. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1912. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1913. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1914. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1915. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1916. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1917. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1918. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1919. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1920. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1921. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1922. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1923. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1924. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1925. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1926. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1927. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1928. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1929. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1930. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1931. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1932. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1933. X -1  -1  -1  -1  -1  -1 
  1934. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1935. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1936. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1937. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1938. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1939. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1940. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1941. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1942. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1943. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1944. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1945. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1946. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1947. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1948. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1949. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1950. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1951. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1952. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1953. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1954. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1955. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1956. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1957. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1958. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1959. X -1  -1  -1  -1  -1  -1 
  1960. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1961. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1962. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1963. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1964. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1965. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1966. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1967. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1968. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1969. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1970. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1971. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1972. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1973. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1974. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1975. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1976. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1977. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1978. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1979. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1980. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1981. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1982. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1983. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1984. X -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
  1985. X -1  -1  -1  -1  -1  -1 
  1986. END_OF_zeecode.perm
  1987. if test 11550 -ne `wc -c <zeecode.perm`; then
  1988.     echo shar: \"zeecode.perm\" unpacked with wrong size!
  1989. fi
  1990. # end of overwriting check
  1991. fi
  1992. echo shar: End of archive 5 \(of 11\).
  1993. cp /dev/null ark5isdone
  1994. MISSING=""
  1995. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  1996.     if test ! -f ark${I}isdone ; then
  1997.     MISSING="${MISSING} ${I}"
  1998.     fi
  1999. done
  2000. if test "${MISSING}" = "" ; then
  2001.     echo You have unpacked all 11 archives.
  2002.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2003. else
  2004.     echo You still need to unpack the following archives:
  2005.     echo "        " ${MISSING}
  2006. fi
  2007. ##  End of shell archive.
  2008. exit 0
  2009.